<template>
  <div class="charts" ref="charts"></div>
</template>

<script>
  import echarts from "echarts";
  export default {
    computed: {},
    components: {},
    mounted() {
     let  option = {
    tooltip: {
      trigger: 'axis',
    },
    dataset: {
      source: [
        ['product', '2018', '2019', '2020', '2021', '2022', '2023'],
        ['支付宝', 56.5, 82.1, 88.7, 70.1, 53.4, 85.1],
        ['微信', 51.1, 51.4, 55.1, 53.3, 73.8, 68.7],
        ['云闪付', 40.1, 62.2, 69.5, 36.4, 45.2, 32.5],
        ['数字人民币', 25.2, 37.1, 41.2, 18, 33.9, 49.1]
      ]
    },
    xAxis: { type: 'category' ,show:false},
    yAxis: { gridIndex: 0,show:false },
    // grid: { top: '55%' },
    series: [
      {
        type: 'line',
        smooth: true,
        seriesLayoutBy: 'row',
        emphasis: { focus: 'series' }
      },
      {
        type: 'line',
        smooth: true,
        seriesLayoutBy: 'row',
        emphasis: { focus: 'series' }
      },
      {
        type: 'line',
        smooth: true,
        seriesLayoutBy: 'row',
        emphasis: { focus: 'series' }
      },
      {
        type: 'line',
        smooth: true,
        seriesLayoutBy: 'row',
        emphasis: { focus: 'series' }
      },
      {
        type: 'pie',
        id: 'pie',
        radius: '30%',
        center: ['50%', '25%'],
        emphasis: {
          focus: 'self'
        },
        label: {
          formatter: '{b}: {@2012} ({d}%)'
        },
        encode: {
          itemName: 'product',
          value: '2012',
          tooltip: '2012'
        }
      }
    ],
    grid:{
top: "55%",
show: false,
z: 0,
left: "10%",
right:" 10%",
bottom: 0,
containLabel: false,
backgroundColor: "rgba(0,0,0,0)",
borderColor: "#ccc",
  }
  };
      let lineCharts = echarts.init(this.$refs.charts);
      lineCharts.on('updateAxisPointer', function (event) {
    const xAxisInfo = event.axesInfo[0];
    if (xAxisInfo) {
      const dimension = xAxisInfo.value + 1;
      lineCharts.setOption({
        series: {
          id: 'pie',
          label: {
            formatter: '{b}: {@[' + dimension + ']} ({d}%)'
          },
          encode: {
            value: dimension,
            tooltip: dimension
          }
        }
      });
    }
  });
      lineCharts.setOption(option);
    },
  };
</script>

<style lang="scss" scoped>
.charts {
  width: 100%;
  height: 100%;
}
</style>
